function parentlogin(){
	
	var email = $('#parentlogin_email').val();
	var password = $('#parentlogin_pwd').val();
	
	if(email == '' || password == '')
		return;
	
	var data = {
		"email": email,
		"password": password
	}; 
		
	var url;
	if(document.domain=="localhost")
	{
		//url="http://localhost/lifeinclass/php/parentLogin.php";
	}else{
		//url="php/parentLogin.php";
	}
	
	$.ajax({
	type: "POST",
	dataType: "json",
	url: url, 
	data: data,
	success: function(data) {
		console.debug(data);
		if(data.error == "false"){
			document.getElementById('parentlogin_email').value='';
			document.getElementById('parentlogin_pwd').value='';
			
			var parentdata = {
				"id": data.list.id,
				"parent": data.list.parent
			};
			
			$.cookie('parent', parentdata, { expires: 1 });

			window.location.href = "studentprofile.html"
		}
	},
	error: function(e) {
		console.debug(e);
	}
	}); 
}

function schoollogin(){
	
	var email = $('#schoollogin_email').val();
	var password = $('#schoollogin_pwd').val();
	
	if(email == '' || password == '')
	{
		$("#alertMsg").html("Email or Password field is empty.");
		$('#alertModal').modal('show');
		return;
	}
	
	var data = {
		"email": email,
		"password": password
	}; 
		
	var url;
	if(document.domain=="localhost")
	{
		url="http://localhost/lifeinclass/php/schoolLogin.php";
	}else{
		url="php/schoolLogin.php";
	}
	
	$.ajax({
	type: "POST",
	dataType: "json",
	url: url, 
	data: data,
	success: function(data) {
		console.debug(data);
		if(data.error == "false"){
			document.getElementById('schoollogin_email').value='';
			document.getElementById('schoollogin_pwd').value='';
			
			var schooldata = data.list.id +"/"+ data.list.school +"/"+ data.list.name;
			$.cookie('school', schooldata, { expires: 1 });

			window.location.href = "schoolcontrolpanel.html"
		}else
		{
			$("#alertMsg").html("Login failed.Please check email and password.");
			$('#alertModal').modal('show');
		}
	},
	error: function(e) {
		console.debug(e);
	}
	}); 
}

$("#forgotPwdSchoolLogin").click(function () {
	var email = $('#schoollogin_email').val();
	
	if(email == '')
		return;

    var data = {
		"email": email
	}; 
		
	var url;
	if(document.domain=="localhost")
	{
		url="http://localhost/lifeinclass/php/forgotSchoolLogin.php";
	}else{
		url="php/forgotSchoolLogin.php";
	}
	
	$.ajax({
	type: "POST",
	dataType: "json",
	url: url, 
	data: data,
	success: function(data) {
		console.debug(data);
		if(data.error == "false"){
			document.getElementById('schoollogin_email').value='';
			document.getElementById('schoollogin_pwd').value='';

		}
	},
	error: function(e) {
		console.debug(e);
	}
	}); 
 });
